package com.spzx.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.product.domain.ProductSku;
import com.spzx.product.mapper.ProductSkuMapper;
import com.spzx.product.service.ProductSkuService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

@Service
public class ProductSkuServiceImpl extends ServiceImpl<ProductSkuMapper , ProductSku>
implements ProductSkuService {
    //保证数据一致性： 更新sku数据时，无论它是否有缓存，更新成功时 删除redis中的指定缓存
    @CacheEvict(value = "spzx:channel:cache"  , key ="'item:'+#productSku.id")
    @Override
    public void updateSkuById(ProductSku productSku) {
        baseMapper.updateById(productSku);
    }
}
